﻿using Furion.DatabaseAccessor;
using Microsoft.AspNetCore.Identity;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text;

namespace Mrhd.Core.Entities
{
    /// <summary>
    /// 用户地址表
    /// </summary>
    [Table("Sys_Address")]
    [Comment("用户地址表")]
    public class AddressEntity : Entity, IEntityTypeBuilder<AddressEntity>
    {
        /// <summary>
        /// 纬度
        /// </summary>
        [Comment("纬度")]
        public double Lat { get; set; }
        /// <summary>
        /// 经度
        /// </summary>
        [Comment("经度")]
        public double Lng { get; set; }
        /// <summary>
        /// 定位地址
        /// </summary>
        [Comment("定位地址")]
        [MaxLength(512)]
        public string Title { get; set; }
        /// <summary>
        /// 详细地址
        /// </summary>
        [Comment("详细地址")]
        [MaxLength(512)]
        public string Detail { get; set; }
        /// <summary>
        /// 电话
        /// </summary>
        [Comment("电话")]
        [MaxLength(32)]
        public string Phone { get; set; }
        /// <summary>
        /// 联系人
        /// </summary>
        [Comment("联系人")]
        [MaxLength(32)]
        public string Contacts { get; set; }
        /// <summary>
        /// 关联的用户id
        /// </summary>
        [Comment("关联的用户id")]
        public int? UserId { get; set; }
        /// <summary>
        /// 用户实体
        /// </summary>
        [Comment("用户实体")]
        public virtual UserEntity User { get; set; }

        public void Configure(EntityTypeBuilder<AddressEntity> entityBuilder, DbContext dbContext, Type dbContextLocator)
        {
            entityBuilder.HasIndex(a => a.UserId);
        }
    }

}
